<link href="/css/bootstrap.min.css" rel="stylesheet"/> 
<link href="/templates/admin/css/admin_default.css" rel="stylesheet"/> 
<script type="text/javascript" src="/js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="/js/select-chain.js"></script>
<script type="text/javascript" src="/js/CLEditor1_4_2/jquery.cleditor.min.js"></script>
<link href="/js/CLEditor1_4_2/jquery.cleditor.css" rel="stylesheet"/>
<script type="text/javascript">
    var obj = {
        width:        500, // width not including margins, borders or padding
        height:       100, // height not including margins, borders or padding
        controls:     // controls to add to the toolbar
          "bold italic underline strikethrough subscript superscript | font size " +
          "style | color highlight removeformat | bullets numbering | outdent " +
          "indent | alignleft center alignright justify ",
        colors:       // colors in the color popup
          "FFF FCC FC9 FF9 FFC 9F9 9FF CFF CCF FCF " +
          "CCC F66 F96 FF6 FF3 6F9 3FF 6FF 99F F9F " +
          "BBB F00 F90 FC6 FF0 3F3 6CC 3CF 66C C6C " +
          "999 C00 F60 FC3 FC0 3C0 0CC 36F 63F C3C " +
          "666 900 C60 C93 990 090 399 33F 60C 939 " +
          "333 600 930 963 660 060 366 009 339 636 " +
          "000 300 630 633 330 030 033 006 309 303",
        fonts:        // font names in the font popup
          "Arial,Arial Black,Comic Sans MS,Courier New,Narrow,Garamond," +
          "Georgia,Impact,Sans Serif,Serif,Tahoma,Trebuchet MS,Verdana",
        sizes:        // sizes in the font size popup
          "1,2,3,4,5,6,7",
        styles:       // styles in the style popup
          [["Paragraph", "<p>"], ["Header 1", "<h1>"], ["Header 2", "<h2>"],
            ["Header 3", "<h3>"],  ["Header 4","<h4>"],  ["Header 5","<h5>"],
            ["Header 6","<h6>"]],
        useCSS:       false, // use CSS to style HTML when possible (not supported in ie)
        docType:      // Document type contained within the editor
          '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">',
        docCSSFile:   // CSS file used to style the document contained within the editor
          "",
        bodyStyle:    // style to assign to document body contained within the editor
          "margin:4px; font:10pt Arial,Verdana; cursor:text"}
          
    $(document).ready(function () { $(".card_content").cleditor(obj).updateTextArea; });
  </script>
  
<?php if($this->error){ ?>
	<div class="notification error" >
		<span class="strong">Error:</span>
		<?php echo $this->error; ?>.
		<span class="close" title="Dismiss"></span>
	</div>
<?php }?>
<?php if($this->warning){ ?>
	<div class="notification warning" >
		<span class="strong">Warning:</span>
		<?php echo $this->warning; ?>
		<span class="close" title="Dismiss"></span>
	</div>
<?php }?>

<?php $item = $this->arrParam; ?>


<form name="editor" action="" method="post" enctype="application/x-www-form-urlencoded">     
<div id="main-content">
<div class="news-content">
    <label>Trạng thái:</label>
      <div>
               <select name="status">
                <option value="1" >ON</option>
                <option value="0" >OFF</option>
                </select>
            </div>
</div>
<div class="news-content">
            <label>Lựa chọn Category:</label>
            <div>
               <select name="select-category" id="select-category">
               <?php foreach($this->listType as $filmtype){ 
                    $item_type = explode('|',$item['type']);
                ?>
                <option value="<?php echo $filmtype['id']?>" <?php  if ($item['0']==$filmtype['id']) echo "selected='selected'"?>><?php echo $filmtype['name']?></option>
                <?php }?>
                </select>
            </div>
</div>
<script>
    $("#select-category").change(function () {
          var str = "1";
          var scntDiv = $('#select-box');
          $("#select-category option:selected").each(function () {
                str = $(this).val();
                $(".cate-all").css('display','none');
                $("#cate-"+str).css('display','block')
              });
    }).trigger('change');
</script>

<?php
        $category = 1;
        //Zend_Debug::dump($this->listType);die;
        foreach($this->listType as $type){
            $category = $type['id'];
            $item_type = explode('|',$type['name_types']);
            for($i = 0;$i < count($item_type); $i++){
                    $item_type[$i] = explode('-',$item_type[$i]);
            };
            $count = count($item_type);
?>
<div class="news-content cate-all" id="cate-<?php echo $category?>" style="display: <?php if($category==1)echo"block";else echo"none"; ?>;">
            <label>Lựa chọn chuyên mục:</label>
            <div>
            <select multiple="multiple" name="select-type-<?php echo $category?>[]" id="select-type-<?php echo $category?>">
<?php
            for($i = 0;$i<$count;$i++){
                echo "<option value='".$item_type[$i][0]."'>".$item_type[$i][1]."</option>";
            }
            ?>
           </select>
            </div>
</div>  
<?php
        };
?>
<!--<div class="news-content">
            <label>Lựa chọn chuyên mục:</label>
            <div>
               <select name="select-type" id="select-type">
                    <option></option>
                </select>
            </div>
</div>-->
<div class="news-content">
    <label>Tiêu đề việt:</label>
<!--     <input type='text' name="header" value="<?php echo $item['title_vi'] ?>"/>
-->     <textarea class="textarea1" name="title_vi"><?php echo $item['title_vi'] ?></textarea>
</div>
<div class="news-content">
    <label>Tiêu đề Tiếng anh:</label>
<!--     <input type='text' name="header" value="<?php echo $item['title_en'] ?>"/>
-->     <textarea class="textarea1" name="title_en"><?php echo $item['title_en'] ?></textarea>
</div>

<div class="news-content">
    <label>Năm phát hành: </label>
    <input type="text"  id="year" name="year" value="<?php echo stripslashes($item['year']);?>"/>
</div>

<div class="news-content">
    <label>
    Quốc gia / Ca sĩ:
    </label>
    <input type="text"  id="national" name="national" value="<?php echo stripslashes($item['national']);?>"/>
</div>
<div class="news-content">
    <label>
    Nguồn *
    </label>
    <input type="text"  id="source" name="source" value="<?php echo stripslashes($item['source']);?>" required="required"/>
</div>

<div class="news-content">
    <label>Banner:</label>
    <input type="text"  id="banner" name="banner" value="<?php echo stripslashes($item['banner']);?>"/>
    <input type="checkbox" name="check-banner" id="check-banner"/>
</div>

<div class="news-content">
    <label>Chọn ảnh:</label>
    <input type="text" value="" id="urlSelectImg" name="urlSelectImg" style="display: none;" />
    <input type="button" value="Upload" id="btnSelectImg" name="btnSelectImg" class="btn btn-success" />
    <div id="displayImages"><img height=72 width=72 class='images' src="<?php echo $item['thumb'];?>"/></div>
</div>

<div class="news-content">
    <label>Kiểu video</label>
    <?php echo $this->formSelect("type_data_ep",$item['type_data_ep'],null,array("0"=>"Link Youtube","1"=>"Mã nhúng",))?>
    <span style="color: red;margin-left: 8px;">***Chú ý chọn đúng kiểu dữ liệu của video</span>
</div>
<div class="news-content">
    <label>Type play:</label>
      <div>
               <select name="typeplay">
                <option value="1" >Chơi Video</option>
                <option value="2" > Video + Mp3</option>
                <option value="3" > Mp3</option>
                </select>
            </div>
</div>
<div class="news-content">
    <label>Số tập phim:</label>
    <input readonly="readonly" type="text"  id="number_ep" name="number_ep" value="<?php if(stripslashes($item['number_ep'])!= "")echo stripslashes($item['number_ep']);else echo"1";?>"/>
    <input readonly="readonly" type="hidden"  id="del_ep" name="del_ep" value="0"/>
    <input readonly="readonly" type="hidden"  id="add_ep" name="add_ep" value="1"/>
</div>
<div id="div_scents"> 
    <div class="news-content">
        <label>Link/ Mã nhúng tập 1:</label>
        <input placeholder="Tiêu đề" type="text"  id="des-1" name="des-1" value="<?php echo stripslashes($item['des-1']);?>"/>
        <textarea class="textarea" placeholder="Link/ Mã nhúng"  id="ep-1" name="ep-1"><?php echo stripslashes($item['ep-1']);?></textarea>
        <textarea class="card_content" placeholder="Mã nhạc chờ" id="card-1" name="card-1"><?php echo stripslashes($item['card-1']);?></textarea>
        <textarea class="textarea" placeholder="link_mp3" id="mp3-1" name="mp3-1"><?php echo stripslashes($item['mp3-1']);?></textarea>
        <a href="#" id="remScnt" class="'+i+'"> Xóa</a>
    </div>
</div>
<h2><a href="#" id="addScnt"><button>Thêm tập</button></a></h2>
<script>
	$(document).ready(function(){
        var scntDiv = $('#div_scents');
        var i = $('#div_scents div').size() - 32;
        var del = parseInt($('#del_ep').val());
        var add = parseInt($('#add_ep').val());
        var number_ep = parseInt($('#number_ep').val());
        $('#addScnt').live('click',function() {
                
                add = parseInt($('#add_ep').val());
                $('#add_ep').val(add + 1);
                
                number_ep = parseInt($('#number_ep').val());
                $('#number_ep').val(number_ep+1);
                
                $('<div class="news-content"><label for="ep-'+i+'">Link/ Mã nhúng tập '+i+':</label><input placeholder="Tiêu đề" type="text" id="des-'+i+'" size="20" name="des-' + i +'" value="" /><textarea class="textarea" placeholder="Link/ Mã nhúng" type="text" id="ep-'+i+'" size="20" name="ep-' + i +'"></textarea><textarea class="card_content" placeholder="Mã nhạc chờ" id="card-'+i+'" name="card-'+i+'"></textarea><textarea class="textarea" placeholder="Link mp3" id="mp3-'+i+'" name="mp3-'+i+'"></textarea><a href="#" id="remScnt" class="'+i+'"> Xóa</a></div>').appendTo(scntDiv);
                i++;
                $(".card_content").cleditor(obj);
                return false;
        });
        $('#remScnt').live('click', function() {
             //   if( i-del > 2 ) {
                       $(this).parents('div.news-content').remove();
                        
                        del = parseInt($('#del_ep').val());
                        $('#del_ep').val(del + 1);
                        
                        number_ep = parseInt($('#number_ep').val());
                        $('#number_ep').val(number_ep-1);

              //  }
                return false;
        });
});
</script>

<div class="mo-ta">
    <label>Mô tả:</label>
    <textarea  id="newscontent" name="description"><?php echo stripslashes($item['description']);?></textarea>
</div>

<div class="news-content">
    <input type="submit" value="Ðăng bài" class="btn btn-success"/>
</div>

<div class="mo-ta">
    <label>Từ khóa:</label>
    <textarea  id="newscontent" name="keywords"><?php echo stripslashes($item['keywords']);?></textarea>
</div>

<div class="news-content">
    <input type="submit" value="Ðăng bài" class="btn btn-success"/>
</div>

</div>
</form>
 <script>
               CKEDITOR.replace('newscontent',{
                   fullpage:true,
                   extraPlugins:'docprops',
                   skin:'office2003',
                   
                   extraPlugins : 'autogrow',
	               autoGrow_maxHeight : 600,
                   removePlugins : 'resize'
               });
 </script>
 
 